<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
  <title>Description of softmin</title>
  <meta name="keywords" content="softmin">
  <meta name="description" content="Calculates the softmin of a vector.">
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="generator" content="m2html &copy; 2003 Guillaume Flandin">
  <meta name="robots" content="index, follow">
  <link type="text/css" rel="stylesheet" href="../m2html.css">
</head>
<body>
<a name="_top"></a>
<!-- menu.html classify -->
<h1>softmin
</h1>

<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong>Calculates the softmin of a vector.</strong></div>

<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong>function M = softmin( D, sigma ) </strong></div>

<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="fragment"><pre class="comment"> Calculates the softmin of a vector.

 Let d be a vector.  Then the softmin of d is defined as:
   s = exp(-d/sigma^2) / sum( exp(-d/sigma^2) )
 The softmin is a way of taking a dissimilarity (distance) vector d and converting it to
 a similarity vector s, such that sum(s)==1.  

 Note that as sigma-&gt;0, softmin's behavior tends toward that of the standard min
 function.  That is the softmin of a vector d has all zeros with a single 1 in the
 location of the smallest value of d. For example, &quot;softmin([.2 .4 .1 .3],eps)&quot; returns
 &quot;[0 0 1 0]&quot;.  As sigma-&gt;inf, then softmin(d,sigma) tends toward &quot;ones(1,n)/n&quot;, where
 n==length(d).

 If D is an NxK array, is is treated as N K-dimensional vectors, and the return is
 likewise an NxK array.  This is useful if D is a distance matrix, generated by the likes
 of dist_euclidean or dist_chisquared.

 If d contains the squared euclidean distance between a point y and k points xi, then
 there is a probabilistic interpretation for softmin.  If we think of the k points
 representing equal variant gaussians each with mean xi and std sigma, then the softmin
 returns the relative probability of y being generated by each gaussian.

 INPUTS
   D       - NxK dissimilarity matrix 
   sigma   - controls 'softness' of softmin

 OUTPUTS
   M       - the softmin

 EXAMPLE
   % example 1
   C = [0 0; 1 0; 0 1; 1 1]; x=[.7,.3; .1 .2];
   D = dist_euclidean( x, C );
   M = softmin( D, 1 )
   % example 2
   fplot( 'softmin( [0.5 0.2 .4], x )', [eps 10] );

 DATESTAMP
   29-Sep-2005  2:00pm

 See also <a href="dist_euclidean.html" class="code" title="function D = dist_euclidean( X, Y )">DIST_EUCLIDEAN</a>, <a href="dist_chisquared.html" class="code" title="function D = dist_chisquared( X, Y )">DIST_CHISQUARED</a></pre></div>

<!-- crossreference -->
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
This function calls:
<ul style="list-style-image:url(../matlabicon.gif)">
<li><a href="../images/imsubs2array.html" class="code" title="function I = imsubs2array( subs, vals, siz, fillval )">imsubs2array</a>	Converts subs/vals image representation to array representation.</li></ul>
This function is called by:
<ul style="list-style-image:url(../matlabicon.gif)">
</ul>
<!-- crossreference -->



<hr><address>Generated on Wed 03-May-2006 23:48:50 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/" target="_parent">m2html</a></strong> &copy; 2003</address>
</body>
</html>